package com.fish.admin.module.data.faker;

import com.fish.admin.module.data.domain.vo.DataPanelVO;
import com.github.javafaker.Faker;

import java.math.BigDecimal;
import java.util.Locale;

import java.util.Random;

public class DataPanelVOMaker {

    private static final Faker faker = new Faker(Locale.CHINA);
    private static final Random random = new Random();


    /**
     * 使用JavaFaker生成DataPanelVO对象的测试数据
     */
    public static DataPanelVO generateDataPanelVO() {
        DataPanelVO vo = new DataPanelVO();

        // 会员相关数据（整数类型）
        vo.setTodayRegisterNum(faker.number().numberBetween(0, 1000));
        vo.setYesterdayRegisterNum(faker.number().numberBetween(0, 1000));
        vo.setTotal(faker.number().numberBetween(1000, 100000));
        vo.setTodayOnlineNum(faker.number().numberBetween(0, 500));
        vo.setYesterdayOnlineNum(faker.number().numberBetween(0, 500));
        vo.setOnlineNum(faker.number().numberBetween(0, 1000));

        // 收付差相关数据（BigDecimal类型，保留2位小数）
        vo.setTodayPayReceiveDiff(generateRandomBigDecimal(0, 10000));
        vo.setYesterdayPayReceiveDiff(generateRandomBigDecimal(0, 10000));
        vo.setPayReceiveDiff(generateRandomBigDecimal(10000, 1000000));
        vo.setTodayActualPayReceiveDiff(generateRandomBigDecimal(0, 10000));
        vo.setYesterdayActualPayReceiveDiff(generateRandomBigDecimal(0, 10000));
        vo.setActualPayReceiveDiff(generateRandomBigDecimal(10000, 1000000));

        // 代收相关数据
        vo.setTodayCollect(generateRandomBigDecimal(0, 50000));
        vo.setYesterdayCollect(generateRandomBigDecimal(0, 50000));
        vo.setCollect(generateRandomBigDecimal(100000, 10000000));
        vo.setTodayActualCollect(generateRandomBigDecimal(0, 50000));
        vo.setYesterdayActualCollect(generateRandomBigDecimal(0, 50000));
        vo.setActualCollect(generateRandomBigDecimal(100000, 10000000));
        vo.setTodayCollectNum(faker.number().numberBetween(0, 200));
        vo.setYesterdayCollectNum(faker.number().numberBetween(0, 200));
        vo.setCollectNum(faker.number().numberBetween(1000, 50000));
        vo.setTodayCollectCount(faker.number().numberBetween(0, 500));
        vo.setYesterdayCollectCount(faker.number().numberBetween(0, 500));
        vo.setCollectCount(faker.number().numberBetween(1000, 100000));

        // 代付相关数据
        vo.setTodayPay(generateRandomBigDecimal(0, 40000));
        vo.setYesterdayPay(generateRandomBigDecimal(0, 40000));
        vo.setPay(generateRandomBigDecimal(80000, 8000000));
        vo.setTodayActualPay(generateRandomBigDecimal(0, 40000));
        vo.setYesterdayActualPay(generateRandomBigDecimal(0, 40000));
        vo.setActualPay(generateRandomBigDecimal(80000, 8000000));
        vo.setTodayPayNum(faker.number().numberBetween(0, 150));
        vo.setYesterdayPayNum(faker.number().numberBetween(0, 150));
        vo.setPayNum(faker.number().numberBetween(800, 40000));
        vo.setTodayPayCount(faker.number().numberBetween(0, 400));
        vo.setYesterdayPayCount(faker.number().numberBetween(0, 400));
        vo.setPayCount(faker.number().numberBetween(800, 80000));

        // 首充相关数据
        vo.setTodayFirstChargeNum(faker.number().numberBetween(0, 100));
        vo.setYesterdayFirstChargeNum(faker.number().numberBetween(0, 100));
        vo.setFirstChargeNum(faker.number().numberBetween(500, 30000));
        vo.setTodayFirstChargeCount(faker.number().numberBetween(0, 150));
        vo.setYesterdayFirstChargeCount(faker.number().numberBetween(0, 150));
        vo.setFirstChargeCount(faker.number().numberBetween(800, 50000));
        vo.setTodayFirstCharge(generateRandomBigDecimal(0, 30000));
        vo.setYesterdayFirstCharge(generateRandomBigDecimal(0, 30000));
        vo.setFirstCharge(generateRandomBigDecimal(50000, 5000000));

        // 复充相关数据
        vo.setTodayRepeatChargeNum(faker.number().numberBetween(0, 200));
        vo.setYesterdayRepeatChargeNum(faker.number().numberBetween(0, 200));
        vo.setRepeatChargeNum(faker.number().numberBetween(1000, 60000));
        vo.setTodayRepeatChargeCount(faker.number().numberBetween(0, 300));
        vo.setYesterdayRepeatChargeCount(faker.number().numberBetween(0, 300));
        vo.setRepeatChargeCount(faker.number().numberBetween(1500, 100000));
        vo.setTodayRepeatCharge(generateRandomBigDecimal(0, 50000));
        vo.setYesterdayRepeatCharge(generateRandomBigDecimal(0, 50000));
        vo.setRepeatCharge(generateRandomBigDecimal(100000, 8000000));

        // 下单相关数据
        vo.setTodayOrderNum(faker.number().numberBetween(0, 300));
        vo.setYesterdayOrderNum(faker.number().numberBetween(0, 300));
        vo.setOrderNum(faker.number().numberBetween(2000, 80000));
        vo.setTodayOrder(generateRandomBigDecimal(0, 60000));
        vo.setYesterdayOrder(generateRandomBigDecimal(0, 60000));
        vo.setOrders(generateRandomBigDecimal(150000, 10000000));

        // 派彩相关数据
        vo.setTodayDispatch(generateRandomBigDecimal(0, 40000));
        vo.setYesterdayDispatch(generateRandomBigDecimal(0, 40000));
        vo.setDispatch(generateRandomBigDecimal(100000, 6000000));

        // 游戏盈亏相关数据
        vo.setTodayGameProfit(generateRandomBigDecimal(-20000, 50000));
        vo.setYesterdayGameProfit(generateRandomBigDecimal(-20000, 50000));
        vo.setGameProfit(generateRandomBigDecimal(-100000, 10000000));

        return vo;
    }

    /**
     * 生成指定范围内的随机BigDecimal数值（保留2位小数）
     */
    private static BigDecimal generateRandomBigDecimal(double min, double max) {
        double randomValue = min + (max - min) * random.nextDouble();
        return BigDecimal.valueOf(randomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
    }
}
